home *** CD-ROM | disk | FTP | other *** search
- MODULE 'tools/file', 'tools/thx-play', 'arp', 'exec/memory', 'dos/dos'
-
- ENUM ARG_FILES,ARG_NOREP,ARG_FADE
-
- PROC main() HANDLE
- DEF args:PTR TO LONG,rdargs=0,template,file,files:PTR TO LONG
-
- args:=[0,0,0]; template:='PLAYLIST/M,NOREPEAT/S,FADE/S'
- IF KickVersion(36)
- rdargs:=ReadArgs(template,args,NIL)
- ELSE
- IF arpbase:=OpenLibrary('arp.library',39)
- GaDS(arg,StrLen(arg),template,args,NIL)
- ELSE
- WriteF('Needs arp.library v39\n')
- RETURN 20
- ENDIF
- ENDIF
-
- IF files:=args[ARG_FILES] THEN WHILE file:=files[]++ DO play(file,args[ARG_NOREP],args[ARG_FADE])
-
- Raise(0)
- EXCEPT
- thxFree() -> only free all resources _ONCE_ :)
- IF arpbase THEN CloseLibrary(arpbase)
- IF rdargs THEN FreeArgs(rdargs)
- ENDPROC
-
- PROC play(name,norep,fade)
- DEF mod,len,vol,sig,cont=TRUE
-
- mod,len:=readfile(name)
- IF mod=0
- WriteF('Can\at read file "\s"\n"',name)
- RETURN
- ENDIF
-
- WriteF('Now playing "\s".\nPress CTRL-C to skip, CTRL-D to stop. '+
- 'CTRL-F will fast-forward.\n',name)
-
- IF thxInit(mod)<>0
- WriteF('Can\at start player.\n')
- freefile(mod)
- RETURN
- ENDIF
-
- -> if we are not to repeat, then set THX to break us at the end.
- IF norep THEN thxSignalEnd(SIGBREAKF_CTRL_C)
-
- thxSetVolume(64)
- thxPlay() -> start play
-
- WHILE cont
- sig:=Wait(SIGBREAKF_CTRL_C OR SIGBREAKF_CTRL_D OR SIGBREAKF_CTRL_F)
- IF sig AND SIGBREAKF_CTRL_F
- thxWind(1)
- ELSE
- cont:=FALSE
- ENDIF
- ENDWHILE
-
- IF fade
- FOR vol:=64 TO 0 STEP -1
- WaitTOF()
- thxSetVolume(vol)
- ENDFOR
- ENDIF
-
- thxStop() -> no longer use the mod, we can free the memory.
-
- freefile(mod)
- IF sig AND SIGBREAKF_CTRL_D THEN Raise("stop") -> pop out of loop in main()
- ENDPROC
-